home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 1 of 3 / INCLUDE / GENSTUB.C < prev    next >
C/C++ Source or Header  |  1995-04-18  |  2KB  |  59 lines

  1. #include <windows.h>
  2. #include <generic.h>
  3.  
  4.  
  5. LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
  6.  
  7. HINSTANCE hInst;   // current instance
  8.  
  9. LPCTSTR lpszAppName = "MyApp";
  10. LPCTSTR lpszTitle   = "My Application";
  11.  
  12.  
  13. int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
  14.                       LPTSTR lpCmdLine, int nCmdShow)
  15. {
  16.    MSG      msg;
  17.    HWND     hWnd;
  18.    WNDCLASS wc;
  19.  
  20.    wc.style         = CS_HREDRAW | CS_VREDRAW;
  21.    wc.lpfnWndProc   = (WNDPROC)WndProc;
  22.    wc.cbClsExtra    = 0;
  23.    wc.cbWndExtra    = 0;
  24.    wc.hInstance     = hInstance;
  25.    wc.hIcon         = LoadIcon (hInstance, lpszAppName);
  26.    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
  27.    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  28.    wc.lpszMenuName  = lpszAppName;
  29.    wc.lpszClassName = lpszAppName;
  30.  
  31.    RegisterClass( &wc );
  32.  
  33.    hInst = hInstance;
  34.  
  35.    hWnd = CreateWindow( lpszAppName,
  36.                         lpszTitle,
  37.                         WS_OVERLAPPEDWINDOW,
  38.                         CW_USEDEFAULT, 0,
  39.                         CW_USEDEFAULT, 0,
  40.                         NULL,
  41.                         NULL,
  42.                         hInstance,
  43.                         NULL
  44.                       );
  45.  
  46.    if ( !hWnd )
  47.       return( FALSE );
  48.  
  49.    ShowWindow( hWnd, nCmdShow );
  50.    UpdateWindow( hWnd );
  51.  
  52.    while( GetMessage( &msg, NULL, 0, 0) )
  53.    {
  54.       TranslateMessage( &msg );
  55.       DispatchMessage( &msg );
  56.    }
  57.  
  58.    return( msg.wParam );
  59. }